feat(sucrase): add support for jsxRuntime and other missing Sucrase options#1961
feat(sucrase): add support for jsxRuntime and other missing Sucrase options#1961vinny-silveira wants to merge 10 commits intorollup:masterfrom
Conversation
Co-authored-by: vinny-silveira <13592890+vinny-silveira@users.noreply.github.com>
Remove redundant ternary in resolveId (importer is always truthy), extract common rollup setup into getBundle helper function and add tests for plugin initialization and exclude filter
…port Add support for jsxRuntime and other missing Sucrase transform options
|
Sorry about the copilot noise. I have no idea how that got turned on. But please disregard it. |
|
No worries at all, @shellscape! Totally understand, thanks for the heads-up. Happy to make any changes if needed. |
|
@CharlieHelps please do a thorough review of this PR to determine if it's ready to merge. Look at the diff, reviews, comments, and referenced issues/docs/links to build a complete understanding. Then respond with a comment that includes a list of MUST fix items that must be fixed before the the PR is merged, and a list of IMPROVEMENTS that shouldn't block the merge but may be quick improvements or things that could be addressed in a follow up PR. The MUST fix items should explain exactly what's wrong and what needs to change to resolve the problem. Both should be numbered lists and the IMPROVEMENTS list should continue counting up from the MUST list. It's OK if there are no IMPROVEMENTS or MUST fix items, you can just omit the lists. |
|
I pulled the branch and ran the monorepo checks locally ( MUST fix
IMPROVEMENTS |
Reverts the context: 'this' setting to align with Rollup's default behavior. The context option was added to silence build warnings but has no impact on the plugin's transformation logic. Snapshots updated accordingly.
…port Address review feedback and improve test coverage
|
Thanks for the thorough review, i really appreciate the detailed feedback. I’ve addressed all the points you raised:
|
|
Quick note on the Rollup Just to explain the original rationale behind hard-coding I initially added it to silence Rollup’s build-time warnings about top-level The snapshot change ( |
|
That's fair, and Charlie doesn't always get reviews correct. If you feel that's worth pushing back on, you can revert your "fix" in reply to his review, and add a note in the source to the same effect as your comment above. |
Add the context again to eliminate warnings during test execution.
|
Thanks for the clarification — that makes sense. I’ve reverted the removal and restored context: This remains a bundler-level concern only and doesn’t affect the plugin’s transform behavior in any way. |
|
@vinny-silveira are you using AI to reply to this PR? |
|
No. I only use Google Translate because my native language is Brazilian Portuguese, sorry if that sounds too formal. |
|
OK just checking because no humans use an emdash (—). |
Rollup Plugin Name:
sucraseThis PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
(No specific issues found, but this PR adds support for options that already exist in Sucrase but were not exposed in the plugin.)
Description
This PR adds support for missing Sucrase options that were not being passed through to the
transformfunction:jsxRuntime- Enables the automatic JSX runtime (React 17+);jsxImportSource- Custom JSX import source (e.g.,preact);preserveDynamicImport- Preserve dynamic import expressions;injectCreateRequireForImportRequire- Inject createRequire for import.meta.Additionally, this PR includes:
resolveIdfunction by removing a redundant ternary operator (theimportercheck guarantees it's always truthy at that point);getBundlehelper function to reduce boilerplate in tests, plus new tests for plugin initialization and the exclude filter;